<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width: 100px;
            height: 100px;
            background-color: pink;
            margin: 80px;
            position: relative;
            top: 20px;
            left: 20px;
        }
        .box p{
            width: 50px;
            height: 50px;
            background-color: springgreen;

            position: absolute;
            left: 40px;
            top: 40px;
        }

        button{
            position: fixed;
            top: 200px;
            left: 200px;
        }

        body{
            height: 3000px;
            width: 4000px;
        }

    </style>
</head>
<body>
    <div class="box">
        <p>我是一个端落</p>
    </div>
    <button>固定定位</button>
    <script src="./js/jquery.min.js"></script>
    <script>
        /* 
            1. offset
                获取元素的偏移量,参数物是当前的视口,但是px,此方法只对可见元素有效
        */
        // console.log($(".box").offset());

        // console.log($(".box p").offset());


        /* 
            2. position 获取元素的定位
        */
        // console.log($(".box p").position());

        // console.log($(".box").position());

        // console.log($("button").position());


        /* 
            3. scrollTop 获取卷出的高度
        */
        // $(window).scroll(function(){
        // })

        // $(this).scroll(function(){
        //     console.log($(window).scrollTop());
        //     // console.log($(document).scrollTop());
        // })

        /* 了解 */
        $(window).scroll(function(){
            console.log($(window).scrollLeft());
        })
    </script>
</body>
</html>